<!-- components/global-component.vue -->
<template>
 <view class="global-message">
    <!-- 组件内容 -->
    <text>这是一个全局组件</text>
    <text>当前时间: {{ currentTime }}</text>
  </view>
</template>

<script>
export default {
  data() {
    return {
      currentTime: new Date().toLocaleTimeString()
    }
  },
  mounted() {
    // 每秒更新一次时间
    this.timer = setInterval(() => {
      this.currentTime = new Date().toLocaleTimeString()
    }, 1000)
  },
  beforeDestroy() {
    // 清理定时器
    clearInterval(this.timer)
  }
}
</script>

<style>
.global-message {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background-color: #fff;
  padding: 10px;
  border-radius: 5px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.1);
  z-index: 9999;
}
</style>